package com.example.demo03.dao;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import com.example.demo03.entity.po.TodoItem;

/**
 * The TodoItemMapper interface is a MyBatis mapper interface that provides methods for
 * performing CRUD (Create, Read, Update, Delete) operations on TodoItem entities.
 * It is used to interact with the database through MyBatis framework.
 * MyBatis will generate the implementation of this interface at runtime.
 *
 * @author [Your Name]
 * @version 1.0
 * @since [Date]
 */
@Mapper
public interface TodoItemMapper {

    /**
     * Find all TodoItem objects in the database.
     *
     * @return a list of TodoItem objects
     */
    List<TodoItem> findAll();

    /**
     * Find a TodoItem by its unique identifier.
     *
     * @param id the unique identifier of the TodoItem
     * @return the TodoItem with the specified id, or null if not found
     */
    TodoItem findById(@Param("id") Long id);

    /**
     * Insert a new TodoItem into the database.
     *
     * @param todoItem the TodoItem object to be inserted
     * @return the number of affected rows (usually 1 if the insertion is successful)
     */
    int insert(TodoItem todoItem);

    /**
     * Update an existing TodoItem in the database.
     *
     * @param todoItem the TodoItem object with updated information
     * @return the number of affected rows (usually 1 if the update is successful)
     */
    int update(TodoItem todoItem);

    /**
     * Delete a TodoItem from the database by its unique identifier.
     *
     * @param id the unique identifier of the TodoItem to be deleted
     * @return the number of affected rows (usually 1 if the deletion is successful)
     */
    int deleteById(@Param("id") Long id);

    /**
     * Find the top 10 TodoItems ordered by their score.
     *
     * @return a list of the top 10 TodoItem objects sorted by score
     */
    List<TodoItem> findTop10ByScore();
}